<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/jsp/commons/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page="/jsp/commons/cssinclude.jsp"></jsp:include>
<jsp:include page="/jsp/commons/scriptinclude.jsp"></jsp:include>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>晶品科技信息管理系统-配置管理</title>

</head>
<body>
	 
	<div class="mainbox">

		<div class="main_content">
			 
			<div class="main_right">
				<div class="main_rightbox">
					<div class="ec_crumb_kc">
						<span><a class="icon_up" href="#">上一页</a><a
							class="icon_index" href="${ctx }">首页</a></span>当前位置：配置管理&nbsp;&gt;&nbsp;<em>用户配置</em>
					</div>
				</div>
				<!--品牌基本信息 begin-->
				<div class="ty_border">
					<div class="ty_head">
						<span class="icon4"></span>用户基本信息
					</div>
					<div class="sx_body">
						<form action="${ctx}/user/userAction!edituser.action"
							id="userForm" method="post">
							<input type="hidden" id="hbActionType" value="${actionType}" />
							<input type="hidden" id="id" value="${user.id}" />
							<dl class="clearfix">
								<dt style="display: none;">用户基本信息</dt>

								<dd>
									<label class="name">用户名称：</label><span class="toname"><input
										name="user.name" type="text" value="${user.name}"
										id="userName" title="searchfield" class="winput3" /></span>
									<div class="fl">
										<em id="userNameTip"></em>
									</div>
								</dd>
								<dd>
									<label class="name">用户编码：</label><span class="toname"><input
										name="user.userCode" type="text" value="${ user.userCode}"
										id="userCode" title="searchfield" class="winput3" /></span>
									<div class="fl">
										<em id="userCodeTip"></em>
									</div>
								</dd>
								 
								<dd>
									<label class="name">生日：</label><span class="toname"> 
										<input type="text" id="birthday" class="Wdate" 
										name="user.birthday" style="cursor:pointer" onClick="WdatePicker()" 
										<c:choose>
										<c:when test="${user.birthday eq null}">
										value=""
										</c:when>
										<c:otherwise>
										value="<s:date format='yyyy-MM-dd HH:mm:ss' name='user.birthday'/>"
										</c:otherwise>
										</c:choose>
										 
										/>
										</span>
									<div class="fl">
										<em id="birthdayTip"></em>
									</div>
								</dd>
								<dd>
									<label class="name">性别：</label><span class="toname"> 
										<input type="radio" value="0" 
										<c:if test="${user.sex eq '0'||user.sex eq null}">
										 checked="checked" 
										</c:if>
										 name="user.sex"  class="radioclass" />
		                                <label for="tonamera1">男</label>
		                                <input type="radio" value="1" 
                                        <c:if test="${user.sex eq '1'}">
										 checked="checked" 
										</c:if>
                                        name="user.sex"  class="radioclass" />
		                                <label for="tonamera1">女</label>
										</span>
									<div class="fl">
										<em id="sexTip"></em>
									</div>
								</dd>

								<dd>
									<label class="name">部门：</label><span class="toname">
									 <select id="depart"
										name="user.depart"
										style="border: 1px solid #DDDDDD; color: #999999; float: right; height: 29px; line-height: 29px; padding-left: 5px; width: 218px;">
										 
										<option value="">---请选择---</option>
										<c:forEach items="${lstDepart }" var="path" >
										<option value="${path.code }"  <c:if test="${user.depart eq path.code}">selected="selected"</c:if>>${path.value}</option>
										</c:forEach>
									</select>
									
									
									 </span>
									<div class="fl">
										<em id="departTip"></em>
									</div>
									<button id="btnFindDepart" class="searchBtn dingwei"></button>
									<em class="nomargin">部门在字典表中配置，请选择</em>
								</dd>
								<dd>
									<label class="name">手机：</label><span class="toname"><input
										name="user.mobile" type="text" value="${ user.mobile}"
										id="mobile" title="searchfield" class="winput3" /></span>
									<div class="fl">
										<em id="mobileTip"></em>
									</div>
								</dd>
								<dd>
									<label class="name">E-Mail：</label><span class="toname"><input
										name="user.email" type="text" value="${ user.email}"
										id="email" title="searchfield" class="winput3" /></span>
									<div class="fl">
										<em id="emailTip"></em>
									</div>
								</dd>
								<dd>
									<label class="name">QQ：</label><span class="toname"><input
										name="user.qq" type="text" value="${ user.qq}" id="qq"
										title="searchfield" class="winput3" /></span>
									<div class="fl">
										<em id="qqTip"></em>
									</div>
								</dd>
								<dd>
									<label class="name">办公电话：</label><span class="toname"><input
										name="user.phone" type="text" value="${ user.phone}"
										id="phone" title="searchfield" class="winput3" /></span>
									<div class="fl">
										<em id="phoneTip"></em>
									</div>
								</dd>
								<dd>
									<label class="name">职位：</label><span class="toname"><input
										name="user.station" type="text" value="${ user.station}"
										id="station" title="searchfield" class="winput3" /></span>
									<div class="fl">
										<em id="stationTip"></em>
									</div>
								</dd>
								
								<dd>
									<label class="name">职责：</label><span class="toname"> 
										<textarea
											id="duty" title="searchfield" name="user.duty" rows="3"
											cols="20" title="searchfield" class="winput3">${ user.intro}</textarea>
										</span>
									<div class="fl">
										<em id="dutyTip"></em>
									</div>
								</dd>

								<dd>
									<label class="name">简历：</label><span class="toname"> <textarea
											id="intro" title="searchfield" name="user.intro" rows="3"
											cols="20">${ user.intro}</textarea>
									</span>
									<div class="fl">
										<em id="introTip"></em>
									</div>
								</dd>

							</dl>

							<div class="baocun">
								<button class="gybg saveBtn" id="btnSave" type="button">保存</button>
								<button class="gybg qxBtn" id='btnQuit' type="button">取消</button>
							</div>
						</form>
						<div class="clear"></div>
					</div>
					<!--保存取消 begin-->

				</div>

			</div>
		</div>

	</div>

	<!-- JQ -->

	<script type="text/javascript">
		//自动生成用户编码
		$("#userName").change(
				function() {
					if ($("#userCode").val() == "") {
						$("#userCodeTip").html(
								setPrompt("onLoad", "正在生成用户编码", "${ctx}"));
						$.post("${ctx}/user/userAction!createUserCode.action",
								{
									random : Math.random(),
									"user.name" : $("#userName").val()
								}, function(data) {
									var jsonData = strToJson(data);
									if (jsonData.flag == "success") {
										$("#userCodeTip").html(
												setPrompt("onSuccess",
														"根据用户名首字母自动生成",
														"${ctx}"));
										$("#userCode").val(jsonData.data);
									} else {
										$("#userCodeTip").html(
												setPrompt("onError",
														jsonData.errorMsg,
														"${ctx}"));
									}
								});
					}
				});

		//根据状态为来决定是增加还是修改
		$("#btnSave")
				.click(
						function() {
							var strActionType = $("#hbActionType").val();
							if (strActionType != "") {
								if (strActionType == 0) {
									//新增操作
									//验证编码
									var vCode = $("#userCode").val();
									if (vCode == "") {
										$("#userCodeTip").html(
												setPrompt("onError",
														"字典编码不能为空，亲输入",
														"${ctx}"));
										$("#userForm").focus();
									} else {
										if (codeValidator($("#userCode").val(),
												"N")) {
											$("#userForm")
													.attr("action",
															"${ctx}/user/userAction!addUser.action");
											$("#userForm").submit();
										} else {
											$("#userForm").focus();
										}
									}
								} else if (strActionType == 1) {
									//修改操作
									$("#userForm")
											.attr("action",
													"${ctx}/user/userAction!updateUser.action");
									$("#userForm").submit();
								} else {
									alert("系统错误，请联系系统管理员！");
								}
							} else {
								alert("系统错误，请联系系统管理员！");
							}
						});

		/**
		 * 验证编码
		 * @param code 编码
		 * @param flag 是否异步
		 */
		function codeValidator(code, flag) {
			var result = false;
			//异步验证
			if (flag == "Y") {
				$.post("${ctx}/user/userAction!codeValidator.action", {
					random : Math.random(),
					"user.userCode" : code
				}, function(jsonData) {
					//var jsonData = strToJson(data);
					if (jsonData.flag == "success") {
						$("#userCodeTip")
								.html(
										setPrompt("onSuccess", jsonData.data,
												"${ctx}"));
						result = true;
					} else {
						$("#userCodeTip").html(
								setPrompt("onError", jsonData.errorMsg,
										"${ctx}"));
					}
				});
			} else {
				//同步验证
				var url = "${ctx}/user/userAction!codeValidator.action";
				var params = {
					"random" : Math.random(),
					"user.userCode" : code
				};
				$.ajax({
					url : url,
					type : 'post',
					data : params,
					async : false,
					dataType : 'json',
					success : function(jsonData) {
						//var jsonData = strToJson(data);
						if (jsonData.flag == "success") {
							$("#userCodeTip").html(
									setPrompt("onSuccess", jsonData.data,
											"${ctx}"));
							result = true;
						} else {
							$("#userCodeTip").html(
									setPrompt("onError", jsonData.errorMsg,
											"${ctx}"));
						}
					},
					error : function() {
						alert("系统错误");
					}
				});
			}
			return result;
		}

		/**
		 *绑定值改变事件
		 */
		$("#userCode").change(
				function() {
					$("#userCodeTip").html(
							setPrompt("onLoad", "正在验证数据，请稍等", "${ctx}"));
					codeValidator($("#userCode").val(), "Y");
				});
		
		/**
		  *选择部门弹出层
		  */
		  $("#btnFindDepart").click(function(){
			  
		  });

		$(".ctnGdpOptionPanel li").hover(function() {
			$(this).addClass("hover");
		}, function() {
			$(this).removeClass("hover");
		});
		$(".arrowname").click(function() {
			var domUl = $(this).parent().find(".ctnGdpOptionPanelMask");
			var domArrow = $(this).find("span.arrowdown");
			if (domArrow.hasClass("arrowUp")) {
				domArrow.removeClass("arrowUp");
				domUl.show();
			} else {
				domArrow.addClass("arrowUp");
				domUl.hide();
			}
		});
		
		//取消事件
		$("#btnQuit").click(function(){
			art.dialog.confirm('你确认放弃页面操作，返回列表？', function(){
				location.href ="${ctx}/user/userAction!initUser.action";
			}, function(){
			     
			});
		});
	</script>
</body>
</html>